package org.javaopenaccess.web.ui.login;

import java.util.HashMap;
import java.util.Map;

import org.javaopenaccess.forms.UserForm;
import org.javaopenaccess.web.ui.Validator;

public class LoginValidator implements Validator{

	
	
	@Override
	public Map<Object, Object> validate(Object object) {
		UserForm form = (UserForm)object;
		//TODO: make this to use validtionUtils from core
		if (form.getUserName()!=null && form.getPassword() != null){
			if (!form.getPassword().isEmpty() && !form.getUserName().isEmpty()){
				return null;
			}
		}		
		Map<Object, Object> errors = new HashMap<Object, Object>();
		errors.put("error", "fields.empty");
		return errors;
	}

}
